package tests;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import pnt.message.Request_Register;
import pnt.message.parser.PNTParser;
import junit.framework.TestCase;

public class testParsingOfRegisterMessage extends TestCase {

	Request_Register r1;
	String s1;
	
	protected void setUp() throws Exception {
		super.setUp();
		
		s1 = 
			"REGISTER * PNT/1.0 \r\n" +
			"Transaction: 2342 \r\n" +
			"User-Auth-Required: Yes \r\n" +
			"Authorization: Any \r\n" +
			"Registered-with: SN:joey \r\n" +
			"From: EN:jay \r\n" +
			"To: SN:joey \r\n" +
			"End-User: EN:jay \r\n" +
			"Application: Skype \r\n" +
			"Instance: 1 \r\n" +
			"Private-endpoints: (192.168.1.1,9823) \r\n" +
			"Ext-endpoints: ConeNAT:{ (207.184.236.84,73) , (23.201.43.2,68) } \r\n" +
			"Expires: 20" +
			"\r\n\r\n\r\n";
			
			InputStream i = new ByteArrayInputStream(s1.getBytes());
			PNTParser p = new PNTParser(i);

			r1 = (Request_Register)p.getNextMessage();
			assert(r1 != null);
	}

	public void testToString(){
		assertEquals(s1.toLowerCase(),r1.toString(" \r\n", "\r\n\r\n\r\n").toLowerCase());
	}

}
